package com.hk.developmentlib.view.itemdecoration;

import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.hk.developmentlib.utills.DeviceUtils;



/**
 * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
 */
public class BaseItemRightDecoration extends RecyclerView.ItemDecoration {
    private int space;

    public BaseItemRightDecoration(Context ct, int space) {

        this.space = DeviceUtils.dip2px(ct, space);
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {

        if (parent.getChildAdapterPosition(view) + 1 == parent.getAdapter().getItemCount()) {
            outRect.right = space/4;
        } else {
            outRect.right = space;
            if(parent.getChildAdapterPosition(view)==0){
                outRect.left=space/4;
            }else{
                outRect.left=0;
            }
        }


    }
}
